package com.itheima.bigevent.validation;

import com.itheima.bigevent.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * ClassName: StateValidation
 * Package: com.itheima.bigevent.validation
 * Description:用于给@State提供校验注解规则
 *
 * @Author: Zhang Peiyuan
 * @Create: 2024-08-20-19:12
 * @Version: v1.0
 */
public class StateValidation implements ConstraintValidator<State, String> {

    /**
     *
     * @param value 将来要校验的数据
     * @param context context in which the constraint is evaluated
     *
     * @return 如果返回true则说明校验通过
     */
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if(!"草稿".equals(value) && !"已发布".equals(value)){
            return false;
        }
        return true;
    }
}
